# TABLE 1
# Authors: Mark Kayser & Kasia Nalewajko
# First created: Feb 28, 2024
# Replicated: Nov 18, 2025

rm(list = ls())

# LOAD PACKAGES -----------------------------------------------------------

if (!require("dplyr")) install.packages("dplyr")
if (!require("estimatr")) install.packages("estimatr")
if (!require("modelsummary")) install.packages("modelsummary")

# LOAD DATA ---------------------------------------------------------------

setwd("set/path/to/folder")

load(file = "./01 data/02 generated data/study1/01results_fullsample_clean.Rda")

# RUN MODEL ----

# PO supporters only

temp <- results %>% 
  filter(outcome != "99") %>% 
  filter(manipulation_check1 == 3 | (is.na(manipulation_check1))) %>% 
  filter(popis == "PO")

basicPO <- lm_robust(formula = outcome ~ exp_condition + experiment_first,
                     fixed_effects = as.factor(voivodeship),
                     data = temp)
interactionPO <- lm_robust(formula = outcome ~ exp_condition*GSparty_id_z + experiment_first,
                           fixed_effects = as.factor(voivodeship),
                           data = temp)

# PiS supporters only

temp <- results %>% 
  filter(outcome != "99") %>% 
  filter(manipulation_check1 == 3 | (is.na(manipulation_check1))) %>% 
  filter(popis == "PiS")

basicPiS <- lm_robust(formula = outcome ~ exp_condition + experiment_first,
                      fixed_effects = as.factor(voivodeship),
                      data = temp)
interactionPiS <- lm_robust(formula = outcome ~ exp_condition*GSparty_id_z + experiment_first,
                            fixed_effects = as.factor(voivodeship),
                            data = temp)

modelsummary(list(basicPO, interactionPO, basicPiS, interactionPiS),
             stars = c('*' = .1, '**' = .05, '***' = .01))




